// Totals will not be correct for all aggregation functions.
// Consider adding aggregation specific fixture (e.g. MetricsP75Field) if your test depends on it.

import type {MetricsApiResponse} from 'sentry/types';

export function MetricsFieldFixture(
  field: string,
  params: Partial<MetricsApiResponse> = {}
): MetricsApiResponse {
  return {
    start: '2021-12-01T16:15:00Z',
    end: '2021-12-02T16:15:00Z',
    query: '',
    meta: [],
    intervals: [
      '2021-12-01T16:15:00Z',
      '2021-12-01T16:30:00Z',
      '2021-12-01T16:45:00Z',
      '2021-12-01T17:00:00Z',
      '2021-12-01T17:15:00Z',
      '2021-12-01T17:30:00Z',
      '2021-12-01T17:45:00Z',
      '2021-12-01T18:00:00Z',
      '2021-12-01T18:15:00Z',
      '2021-12-01T18:30:00Z',
      '2021-12-01T18:45:00Z',
      '2021-12-01T19:00:00Z',
      '2021-12-01T19:15:00Z',
      '2021-12-01T19:30:00Z',
      '2021-12-01T19:45:00Z',
      '2021-12-01T20:00:00Z',
      '2021-12-01T20:15:00Z',
      '2021-12-01T20:30:00Z',
      '2021-12-01T20:45:00Z',
      '2021-12-01T21:00:00Z',
      '2021-12-01T21:15:00Z',
      '2021-12-01T21:30:00Z',
      '2021-12-01T21:45:00Z',
      '2021-12-01T22:00:00Z',
      '2021-12-01T22:15:00Z',
      '2021-12-01T22:30:00Z',
      '2021-12-01T22:45:00Z',
      '2021-12-01T23:00:00Z',
      '2021-12-01T23:15:00Z',
      '2021-12-01T23:30:00Z',
      '2021-12-01T23:45:00Z',
      '2021-12-02T00:00:00Z',
      '2021-12-02T00:15:00Z',
      '2021-12-02T00:30:00Z',
      '2021-12-02T00:45:00Z',
      '2021-12-02T01:00:00Z',
      '2021-12-02T01:15:00Z',
      '2021-12-02T01:30:00Z',
      '2021-12-02T01:45:00Z',
      '2021-12-02T02:00:00Z',
      '2021-12-02T02:15:00Z',
      '2021-12-02T02:30:00Z',
      '2021-12-02T02:45:00Z',
      '2021-12-02T03:00:00Z',
      '2021-12-02T03:15:00Z',
      '2021-12-02T03:30:00Z',
      '2021-12-02T03:45:00Z',
      '2021-12-02T04:00:00Z',
      '2021-12-02T04:15:00Z',
      '2021-12-02T04:30:00Z',
      '2021-12-02T04:45:00Z',
      '2021-12-02T05:00:00Z',
      '2021-12-02T05:15:00Z',
      '2021-12-02T05:30:00Z',
      '2021-12-02T05:45:00Z',
      '2021-12-02T06:00:00Z',
      '2021-12-02T06:15:00Z',
      '2021-12-02T06:30:00Z',
      '2021-12-02T06:45:00Z',
      '2021-12-02T07:00:00Z',
      '2021-12-02T07:15:00Z',
      '2021-12-02T07:30:00Z',
      '2021-12-02T07:45:00Z',
      '2021-12-02T08:00:00Z',
      '2021-12-02T08:15:00Z',
      '2021-12-02T08:30:00Z',
      '2021-12-02T08:45:00Z',
      '2021-12-02T09:00:00Z',
      '2021-12-02T09:15:00Z',
      '2021-12-02T09:30:00Z',
      '2021-12-02T09:45:00Z',
      '2021-12-02T10:00:00Z',
      '2021-12-02T10:15:00Z',
      '2021-12-02T10:30:00Z',
      '2021-12-02T10:45:00Z',
      '2021-12-02T11:00:00Z',
      '2021-12-02T11:15:00Z',
      '2021-12-02T11:30:00Z',
      '2021-12-02T11:45:00Z',
      '2021-12-02T12:00:00Z',
      '2021-12-02T12:15:00Z',
      '2021-12-02T12:30:00Z',
      '2021-12-02T12:45:00Z',
      '2021-12-02T13:00:00Z',
      '2021-12-02T13:15:00Z',
      '2021-12-02T13:30:00Z',
      '2021-12-02T13:45:00Z',
      '2021-12-02T14:00:00Z',
      '2021-12-02T14:15:00Z',
      '2021-12-02T14:30:00Z',
      '2021-12-02T14:45:00Z',
      '2021-12-02T15:00:00Z',
      '2021-12-02T15:15:00Z',
      '2021-12-02T15:30:00Z',
      '2021-12-02T15:45:00Z',
      '2021-12-02T16:00:00Z',
    ],
    groups: [
      {
        by: {},
        totals: {
          [field]: 51292.95404741901,
        },
        series: {
          [field]: [
            443.6200417187068, 471.7512262596214, 632.5356294251225, 538.6063865509535,
            524.4706847412767, 552.1308328866158, 491.4847951529728, 540.5649544109818,
            430.31622543090765, 513.2803858330382, 498.20598088568426, 503.9482408241235,
            496.3081254057422, 530.4951893480746, 510.9472734431329, 534.2121619563322,
            580.24191602519, 582.2308981360263, 628.6978339387008, 569.093042423482,
            625.5703758567254, 529.286046746119, 491.3038256504387, 548.2822063955006,
            569.3739373104116, 579.5492159758986, 483.9070230718182, 529.9636517032774,
            554.3095224302028, 546.8567462459974, 574.3167313021837, 578.9293435905665,
            561.8965496805288, 576.137674866579, 529.6122522035633, 513.9424504410429,
            543.8130703563698, 597.6542214420452, 510.1568375049254, 510.7187029189223,
            433.78137928589973, 539.3227194785493, 436.44338223053234, 607.1985174516628,
            524.8753880194068, 501.7107697990002, 514.0727518760925, 541.2173843758375,
            556.0898842681038, 535.6274044037233, 475.75355633285346, 587.3256393771101,
            494.61335151920775, 643.5242484747213, 519.9786827806394, 534.7536939750254,
            570.1995703475561, 452.91363051761834, 613.7709480932585, 520.9545797679832,
            497.2156651159481, 625.7054147147829, 490.6365344675922, 592.1175307910397,
            564.6276355603038, 514.8572640893523, 484.47902185133046, 597.7622625233755,
            559.1799635501319, 571.7109630540343, 513.212778566814, 549.1636248727518,
            462.32331107946504, 551.0869305265527, 576.872028698758, 636.4899532813711,
            479.0486254908533, 543.761081985735, 488.9454132823779, 536.1309059508741,
            534.9354940989901, 567.6136279473333, 458.8870965420118, 514.9547377042924,
            525.3278756572803, 502.05863531061544, 575.8454944963837, 524.476069016465,
            431.1190903001866, 543.5139624946099, 598.8881832598959, 510.5100592771207,
            541.151976697214, 550.0881388522994, 485.26355742991586, 460.14344601636975,
          ],
        },
      },
    ],
    ...params,
  };
}

export function MetricsTotalCountByReleaseIn24h(): MetricsApiResponse {
  return {
    start: '2021-12-01T16:15:00Z',
    end: '2021-12-02T16:15:00Z',
    query:
      'release:7a82c130be9143361f20bc77252df783cf91e4fc OR release:e102abb2c46e7fe8686441091005c12aed90da99',
    meta: [],
    intervals: [
      '2021-03-17T10:00:00Z',
      '2021-03-17T11:00:00Z',
      '2021-03-17T12:00:00Z',
      '2021-03-17T13:00:00Z',
      '2021-03-17T14:00:00Z',
      '2021-03-17T15:00:00Z',
      '2021-03-17T16:00:00Z',
      '2021-03-17T17:00:00Z',
      '2021-03-17T18:00:00Z',
      '2021-03-17T19:00:00Z',
      '2021-03-17T20:00:00Z',
      '2021-03-17T21:00:00Z',
      '2021-03-17T22:00:00Z',
      '2021-03-17T23:00:00Z',
      '2021-03-18T00:00:00Z',
      '2021-03-18T01:00:00Z',
      '2021-03-18T02:00:00Z',
      '2021-03-18T03:00:00Z',
      '2021-03-18T04:00:00Z',
      '2021-03-18T05:00:00Z',
      '2021-03-18T06:00:00Z',
      '2021-03-18T07:00:00Z',
      '2021-03-18T08:00:00Z',
      '2021-03-18T09:00:00Z',
    ],
    groups: [
      {
        by: {project: '123', release: '7a82c130be9143361f20bc77252df783cf91e4fc'},
        totals: {'sum(session)': 219826},
        series: {
          'sum(session)': [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3444, 14912, 15649, 18019, 16726,
            17540, 16970, 25015, 34686, 46434, 10431,
          ],
        },
      },
      {
        by: {release: 'e102abb2c46e7fe8686441091005c12aed90da99', project: '123'},
        totals: {'sum(session)': 6320},
        series: {
          'sum(session)': [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5809, 400, 22, 26, 12, 19, 8, 0, 19, 5,
            0,
          ],
        },
      },
    ],
  };
}

export function MetricsSessionUserCountByStatusByReleaseFixture(): MetricsApiResponse {
  return {
    start: '2022-01-15T00:00:00Z',
    end: '2022-01-29T00:00:00Z',
    query: '',
    meta: [],
    intervals: [
      '2022-01-15T00:00:00Z',
      '2022-01-16T00:00:00Z',
      '2022-01-17T00:00:00Z',
      '2022-01-18T00:00:00Z',
      '2022-01-19T00:00:00Z',
      '2022-01-20T00:00:00Z',
      '2022-01-21T00:00:00Z',
      '2022-01-22T00:00:00Z',
      '2022-01-23T00:00:00Z',
      '2022-01-24T00:00:00Z',
      '2022-01-25T00:00:00Z',
      '2022-01-26T00:00:00Z',
      '2022-01-27T00:00:00Z',
      '2022-01-28T00:00:00Z',
    ],
    groups: [
      {
        by: {'session.status': 'crashed', release: '1'},
        totals: {
          'session.all': 34,
          'count_unique(sentry.sessions.user)': 1,
        },
        series: {
          'session.all': [0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 11, 0, 0, 0],
          'count_unique(sentry.sessions.user)': [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0,
          ],
        },
      },
      {
        by: {'session.status': 'abnormal', release: '1'},
        totals: {
          'session.all': 1,
          'count_unique(sentry.sessions.user)': 1,
        },
        series: {
          'session.all': [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          'count_unique(sentry.sessions.user)': [
            1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          ],
        },
      },
      {
        by: {'session.status': 'errored', release: '1'},
        totals: {
          'session.all': 451,
          'count_unique(sentry.sessions.user)': 2,
        },
        series: {
          'session.all': [0, 0, 0, 0, 0, 37, 0, 0, 0, 335, 79, 0, 0, 0],
          'count_unique(sentry.sessions.user)': [
            0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 2, 0, 0, 0,
          ],
        },
      },
      {
        by: {'session.status': 'healthy', release: '1'},
        totals: {
          'session.all': 5058,
          'count_unique(sentry.sessions.user)': 3,
        },
        series: {
          'session.all': [0, 0, 0, 0, 0, 2503, 661, 0, 0, 1464, 430, 0, 0, 0],
          'count_unique(sentry.sessions.user)': [
            0, 0, 0, 0, 0, 3, 3, 0, 0, 1, 1, 0, 0, 0,
          ],
        },
      },
      {
        by: {'session.status': 'crashed', release: '2'},
        totals: {
          'session.all': 35,
          'count_unique(sentry.sessions.user)': 2,
        },
        series: {
          'session.all': [1, 0, 0, 0, 0, 0, 0, 0, 0, 23, 11, 0, 0, 0],
          'count_unique(sentry.sessions.user)': [
            1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0,
          ],
        },
      },
      {
        by: {'session.status': 'abnormal', release: '2'},
        totals: {
          'session.all': 1,
          'count_unique(sentry.sessions.user)': 1,
        },
        series: {
          'session.all': [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
          'count_unique(sentry.sessions.user)': [
            1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
          ],
        },
      },
      {
        by: {'session.status': 'errored', release: '2'},
        totals: {
          'session.all': 452,
          'count_unique(sentry.sessions.user)': 1,
        },
        series: {
          'session.all': [1, 0, 0, 0, 0, 37, 0, 0, 0, 335, 79, 0, 0, 0],
          'count_unique(sentry.sessions.user)': [
            1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0,
          ],
        },
      },
      {
        by: {'session.status': 'healthy', release: '2'},
        totals: {
          'session.all': 5059,
          'count_unique(sentry.sessions.user)': 10,
        },
        series: {
          'session.all': [1, 0, 0, 0, 0, 2503, 661, 0, 0, 1464, 430, 0, 0, 0],
          'count_unique(sentry.sessions.user)': [
            1, 0, 0, 0, 0, 10, 3, 0, 0, 4, 3, 0, 0, 0,
          ],
        },
      },
    ],
  };
}
